<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/base2.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/style2.css">
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
		<title>渠道商管理-渠道商账户</title>
	</head>
	<body>
		<div class="page">
			<div class="header">
				<div class="header_top"></div>
				<div class="header_bottom clearfix">
					<div class="header_logo fl">
						<img src="${pageContext.request.contextPath}/images/images/index-logo.png">
					</div>
					<ul class="header_nav clearfix fl">
						<li>
							<a href="order_ddlb_duan.html">订单管理</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath}/supplier/list/pass/1.html" class="on">渠道商管理</a>
						</li>
						<li>
							<a href="financial_zhanghu.html">财务管理</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath}/members/list/1.html">用户管理</a>
						</li>
						<li>
							<a href="money_lb_fafang.html">红包管理</a>
						</li>
						<li>
							<a href="account_zhgl.html">账户管理</a>
						</li>
					</ul>
					<div class="header_user fr">
						<img src="${pageContext.request.contextPath}/images/images/user.png">欢迎您，<i>admin</i><a herf="${pageContext.request.contextPath}//manager/loginout.html">【切换账号】</a>
					</div>
				</div>
			</div>
			<div class="main clearfix">
				<div class="main_menu fl" style="height: 1200px;">
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/supplier/list/pass/1.html">
							<img src="${pageContext.request.contextPath}/images/images/channel_lb.png">
							<p>渠道商列表</p>
						</a>
					</div>
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/supplier/accountList/1.html">
							<img src="${pageContext.request.contextPath}/images/images/channel_account.png">
							<p>渠道商账户</p>
						</a>
					</div>
					<div class="menu_name add_people on">
						<a href="${pageContext.request.contextPath}/supplier/addSupplier.html">
							<img src="${pageContext.request.contextPath}/images/images/channel_add.png">
							<p>添加渠道商</p>
						</a>
					</div>
				</div>
				<div class="main_cont fl">
					<div class="main_cont_top">
						<div class="main_inner clearfix">
							<div class="cont_top_title fl">当前位置：渠道商管理 > 添加渠道商</div>
							<div class="cont_top_time fr"><i><img src="${pageContext.request.contextPath}/images/images/refresh.png">刷新</i></div>
						</div>
					</div>
					<!-- <div class="main_cont_top">
						<div class="main_inner clearfix">
							<div class="cont_top_time fr pr">
								<form>
									<input type="search" placeholder="请输入人员姓名、手机号查询" class="search_txt">
									<input type="submit" value="搜索" class="search pa" style="top:6px;right: 0;">
								</form>
							</div>
						</div>
					</div> -->
					<div class="main_cont_bottom">
						<div class="main_inner">
							<div class="add_mian">
								<form action="${pageContext.request.contextPath}/manager/register.html" method="post" id="myform">
									<div class="zhuce_box pb20">
										<div class="shanghuxx clearfix">
											<div class="shanghuxx_l fl">商户信息</div>
											<div class="shanghuxx_r fl">
												 <p><span>商户名称：</span><input type="text" class="input_txt" id="wSName" name="supplierDO.wSName"><i class="ml15 c999">请确保商户名称与企业资质上一致！</i></p>
												 <p><span>公司地址：</span><select class="gsdz"name="supplierDO.wSCity" id="wSCity">
								 		 				<option value="重庆">重庆</option>
												 	</select>
												 	<select class="gsdz"name="supplierDO.wSDistrict" id="wSDistrict">
													 		<option value="" selected>请选择区(县)</option>
					         								<option value="渝中区">渝中区</option>
															<option value="南岸区">南岸区</option>
															<option value="江北区">江北区</option>
															<option value="沙坪坝区">沙坪坝区</option>
															<option value="九龙坡">九龙坡</option>
															<option value="巴南区">巴南区</option>
															<option value="渝北区">渝北区</option>
															<option value="大渡口区">大渡口区</option>
															<option value="北碚区">北碚区</option>
															<option value="綦江区 ">綦江区</option>
															<option value="长寿区">长寿区</option>
															<option value="江津区">江津区</option>
															<option value="合川区">合川区</option>
															<option value="永川区">永川区</option>
															<option value="南川区">南川区</option>
															<option value="铜梁区">铜梁区</option>
															<option value="潼南区">潼南区</option>
															<option value="黔江区">黔江区</option>
															<option value="荣昌区">荣昌区</option>
															<option value="璧山区">璧山区</option>
															<option value="万州区">万州区</option>
															<option value="涪陵区">涪陵区</option>
												 	</select>
												 	<input type="text" class="input_long" name="supplierDO.wSAddress" id="wSAddress">
												 </p>
												 <p><span>商户类型：</span><select class="shlx" name="adminDO.wARoleId">
														 		 <option value="10">家政服务公司</option>
          							      <option value="11">维修服务公司</option>
          							      <option value="12">整理服务</option>
												 </select></p>
												 <div class="clearfix yewu">
													<p class="fl">主营业务：</p>
													<ul class="clearfix fl" id="wSObject2">
														<li>月嫂</li>
														<li>育婴师</li>
														<li class="on">保姆</li>
														<li>看护老人</li>
														<li>医院护工</li>
														<li>保洁</li>
														<li>长期钟点工</li>
														<li>开锁换锁</li>
														<li>管道疏通</li>
														<li>马桶维修</li>
													</ul>
												</div>
												<div class="clearfix quyu">
													<p class="fl">目标服务区域：</p>
													<ul class="clearfix fl" id="wSServuceDistrict2">
														<li>渝中区</li>
														<li>渝北区</li>
														<li class="on">江北区</li>
														<li>沙坪坝区</li>
														<li>南岸区</li>
														<li>九龙坡区</li>
														<li>大渡口区</li>
														<li>北碚区</li>
														<li>巴南区</li>
													</ul>
												</div>
											</div>
										</div>
										<div class="lianxixx clearfix">
											<div class="lianxixx_l fl">联系信息</div>
											<div class="lianxixx_r fl">
												<p><span>用户名：</span><input type="text" class="input_txt" id="wAUsername" name="adminDO.wAUsername"></p>
												<p><span>密码：</span><input type="password" class="input_txt" name="adminDO.wAPassword" id="wAPassword"></p>
												<p><span>确认密码：</span><input type="password" class="input_txt" id="password" name="password"></p>
												<p><span>商户联系人：</span><input type="text" class="input_txt" name="supplierDO.wSContact" id="wSContact"></p>
												<p><span>联系人电话：</span><input type="text" class="input_txt" name="supplierDO.wSTelephone" id="wSTelephone"></p>
											</div>
										</div>
										<div class="qiyezhizi clearfix">
											<div class="qiyezhizi_l fl">企业资质</div>
											<div class="qiyezhizi_r fl pr">
												<img src="${pageContext.request.contextPath}/images/images/shangchuan.png" id="headimage" name="headimage" style="width:320px;height:200px;">
												<input type="file" class="file" id="headerpic" name="headerpic" onchange="showPicture()">
											</div>
										</div>
										<div class="zc_btn">
											<a href="javascript:void()" value="确认添加" class="zc_add" onclick="tijiao();">
										</div>
									</div>
									
										<input type="hidden" name="supplierDO.wSAttacId" id="wSAttacId" />
										<input type="hidden" name="supplierDO.flag" value="2"/>
										<input type="hidden" name="supplierDO.wSObject" id="wSObject"/>
										<input type="hidden" name="supplierDO.wSServuceDistrict" id="wSServuceDistrict"/>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script>
			$(".yewu li").click(function(){
				if($(this).hasClass("on")){
			        $(this).removeClass("on");
			    }else{
			        $(this).addClass("on");
			    }
			});
			$(".quyu li").click(function(){
				if($(this).hasClass("on")){
			        $(this).removeClass("on");
			    }else{
			        $(this).addClass("on");
			    }
			});
			
			//兼容性浏览器
  			function getObjectURL(file) {
		    	var url = null ; 
		    	if (window.createObjectURL!=undefined) { // basic
		    		url = window.createObjectURL(file) ;
		    	} else if (window.URL!=undefined) { // mozilla(firefox)
		    		url = window.URL.createObjectURL(file) ;
		    	} else if (window.webkitURL!=undefined) { // webkit or chrome
		    		url = window.webkitURL.createObjectURL(file) ;
		    	}
		    	return url ;
		    }
			//上传图片
			function showPicture(){
				var strsrc=getObjectURL($("#headerpic").get(0).files[0]);
				$("#headimage").attr("src",strsrc);
				
			    var formData = new FormData(); 
			    formData.append("file",$("#headerpic").get(0).files[0]); 
				  
				 $.ajax({
					 	type:"post",
					 	url:"/file/upload.json",
					 	data : formData,  
					 	// 告诉jQuery不要去处理发送的数据
					 	processData : false,  
					 	// 告诉jQuery不要去设置Content-Type请求头 
					 	contentType : false, 
						success: function(data){
							$("#wSAttacId").val(data.info);
						}
					});
				 
			}
			
			function logins(){
				window.location = "${pageContext.request.contextPath}/manager/login.html";
			}
			
			function tijiao(){
				var wSName=$("#wSName").val();
				if(wSName==null || wSName==""){
					alert("商户名称不能为空！");
					return false;
				}
				var wSCity=$("#wSCity").val();
				if(wSCity==null || wSCity==""){
					alert("请选择城市！");
					return false;
				}
				var wSDistrict=$("#wSDistrict").val();
				if(wSDistrict==null || wSDistrict==""){
					alert("请选择区域！");
					return false;
				}
				var wSAddress=$("#wSAddress").val();
				if(wSAddress==null || wSAddress==""){
					alert("请输入公司地址！");
					return false;
				}
				var wAUsername=$("#wAUsername").val();
				if(wAUsername==null || wAUsername==""){
					alert("请输入用户名！");
					return false;
				}
				var wAPassword=$("#wAPassword").val();
				if(wAPassword==null || wAPassword==""){
					alert("请输入密码！");
					return false;
				}
				var password=$("#password").val();
				if(password==null || password==""){
					alert("请输入确认密码！");
					return false;
				}
				if(password!=wAPassword){
					alert("请输入密码和确认密码不一致！");
					return false;
				}
				var wSContact=$("#wSContact").val();
				if(wSContact==null || wSContact==""){
					alert("请输入商户联系人！");
					return false;
				}
				
				if(wSContact.length>8){
					alert("请输入不超过8个字的商户联系人！");
					return false;
				}
				var wSTelephone=$("#wSTelephone").val();
				if(wSTelephone==null || wSTelephone==""){
					alert("请输入联系电话！");
					return false;
				}
				if(!(/^1(3|4|5|7|8)\d{9}$/.test(wSTelephone))){    
					alert("请输入有效的手机号码！");    
					return false;  
				} 
				
				var strs="";
				var wSObject2=$("#wSObject2").find("li");
				for(i=0;i<wSObject2.length;i++){ 
					if($(wSObject2[i]).hasClass("on")){
						strs+=" "+wSObject2[i].innerHTML;
					} 
				}
				$("#wSObject").val(strs);
				
				var serv="";
				var wSServuceDistrict2=$("#wSServuceDistrict2").find("li");
				for(i=0;i<wSServuceDistrict2.length;i++){ 
					if($(wSServuceDistrict2[i]).hasClass("on")){
						serv+=" "+wSServuceDistrict2[i].innerHTML;
					} 
				}
				$("#wSServuceDistrict").val(serv);
				
				$("#myform").submit();
			}
			
			$(function(){
			
					$("#wAUsername").change(function() {
						var username = $("#wAUsername").val();
						$.ajax({
							  url: "${pageContext.request.contextPath}/manager/check/"+ username + ".json",
							  success:function(data) {
								
								  if(data == 0) {
									alert("用户名已存在！");
									$("#wAUsername").val("");
								  }
							  }
							});
					});
			});
		</script>
	</body>
</html>
